<template>
	<view class="traspg">
		<!-- 提示窗示例 -->
		<!-- 提示窗示例 -->
		<uni-popup class="traspg" ref="alertDialog" type="dialog">
			<uni-popup-dialog :type="dialogInfo.msgType" :cancelText="dialogInfo.cancelText"
				:confirmText="dialogInfo.confirmText" :title="dialogInfo.title" :content="dialogInfo.content"
				:cancel="dialogInfo.cancel" :confirm="dialogInfo.confirm" @confirm="_dialogConfirm"
				@close="_dialogClose"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import * as systemJs from '../../common/system.js'
	export default {
		props: {
			refd: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				dialogInfo: {
					msgType: '',
					title: '',
					content: '',
					confirmText: '',
					cancelText: '',
					confirm: true,
					cancel: true
				}
			}
		},
		mounted() {
			this.dialogInfo = systemJs.showDialog.dialogInfo
			// console.log(systemJs.showDialog.dialogInfo)
			// #ifdef APP-PLUS
				this.$refs.alertDialog.open()
			// #endif
			
		},
		methods: {
			_dialogConfirm() {
				systemJs.showDialog._dialogConfirm()
			// #ifdef APP-PLUS
				this.back();
			// #endif
						
			},
			_dialogClose() {
				systemJs.showDialog._dialogClose()
				this.back();
			},
			back(){
				let canNavBack = getCurrentPages()
				if (canNavBack && canNavBack.length > 1) {
					uni.navigateBack({
						delta: 1
					})
				} else {
					//如果刷新页面当前页面的路由信息会丢失，所以只能通过原生js的方法退回上一页面
					history.back();
				}
			},
			open(){
				console.log(3232)
				this.$refs.alertDialog.open()
			}
		}
	}
</script>

<style>
	page {
		/* 这一定要设置成透明的背景 */
		background: transparent; 
	}
	.traspg {
		/* 这一定要设置成透明的背景 */
		background: transparent; 
	}
</style>